/*
 * To change this template, choose Tools | Templates
 * and pen the template in the editor.
 */

/*
 * MenuCadastrarCliente.java
 *
 * Created on 16/09/2009, 11:14:00
 */
package JPaneis;

import Conector.Conector;
import Data.Cliente;
import Data.Pessoa;
import Data.ServicoPesca;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import siii.MenuPadrao;


public class MenuCadastrarCliente extends javax.swing.JPanel implements panelTools{

    private MenuPadrao menuPadrao;
    private Conector conector;
    private Cliente cliente;
    private String objetivo;
    private JDialog mensagem;
    private ImageIcon iconeOK;
    private ImageIcon iconeERRO;
    private ImageIcon iconeATENCAO;
    private boolean flagCpf = false;
    private boolean flagCpfBD = true;

    /** Creates new form MenuCadastrarCliente */
    public MenuCadastrarCliente(MenuPadrao m, Conector con) {

        this.menuPadrao = m;
        this.conector = con;
        this.objetivo = "C";        //se for Cadastrar
        initComponents();
        cliFrequencia.setEditable(false);
        cliNumPescador.setEditable(false);
        jButtonBuscar.setVisible(false);
        cliFrequencia.setVisible(false);
        cliNumPescador.setVisible(false);
        jLabelNumPescador.setVisible(false);
        jLabelFrequencia.setVisible(false);
        validaData.setVisible(false);
        validaCPF.setVisible(false);
        iconeOK = new ImageIcon(getClass().getResource("/Images/fish-48x48ok.png"));
        iconeERRO = new ImageIcon(getClass().getResource("/Images/fish-48x48erro.png"));
        iconeATENCAO = new ImageIcon(getClass().getResource("/Images/fish-48x48atencao1.png"));
    }

    public MenuCadastrarCliente(MenuPadrao m, String e, Conector con) {
        this.menuPadrao = m;
        this.conector = con;
        this.objetivo = "A";        //se for Atualizar
        initComponents();
        validaData.setVisible(false);
        validaCPF.setVisible(false);
        iconeOK = new ImageIcon(getClass().getResource("/Images/fish-48x48ok.png"));
        iconeERRO = new ImageIcon(getClass().getResource("/Images/fish-48x48erro.png"));
        iconeATENCAO = new ImageIcon(getClass().getResource("/Images/fish-48x48atencao1.png"));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel18 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        cliObs = new javax.swing.JTextArea();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        cliLastName = new javax.swing.JFormattedTextField();
        cliNick = new javax.swing.JFormattedTextField();
        cliMob = new javax.swing.JFormattedTextField();
        cliName = new javax.swing.JFormattedTextField();
        cliNeigh = new javax.swing.JFormattedTextField();
        cliAddr = new javax.swing.JFormattedTextField();
        jLabel20 = new javax.swing.JLabel();
        cliEmail = new javax.swing.JFormattedTextField();
        jLabel19 = new javax.swing.JLabel();
        cliCity = new javax.swing.JFormattedTextField();
        save = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        cliNasc = new javax.swing.JFormattedTextField();
        cliCep = new javax.swing.JFormattedTextField();
        cliTel = new javax.swing.JFormattedTextField();
        cliCpf = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        cliCart = new javax.swing.JComboBox();
        cliFish = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        cliAddrNum = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        cliSex = new javax.swing.JComboBox();
        cliState = new javax.swing.JComboBox();
        jLabelNumPescador = new javax.swing.JLabel();
        cliNumPescador = new javax.swing.JFormattedTextField();
        jLabelFrequencia = new javax.swing.JLabel();
        cliFrequencia = new javax.swing.JFormattedTextField();
        jButtonBuscar = new javax.swing.JButton();
        validaData = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        validaCPF = new javax.swing.JLabel();
        cliRg = new javax.swing.JFormattedTextField();
        jLabel13 = new javax.swing.JLabel();
        validaSenha6 = new javax.swing.JLabel();
        validaSenha7 = new javax.swing.JLabel();
        validaSenha8 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1000, 550));

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabel18.setText("Cadastro de Cliente");

        cliObs.setColumns(20);
        cliObs.setRows(5);
        cliObs.setName("Observacao"); // NOI18N
        jScrollPane1.setViewportView(cliObs);

        jLabel11.setText("Celular");

        jLabel12.setText("Peixe Preferido");

        cliLastName.setName("Sobrenome"); // NOI18N

        cliNick.setName("Apelido"); // NOI18N

        try {
            cliMob.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliMob.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
        cliMob.setName("Celular"); // NOI18N

        cliName.setName("Nome"); // NOI18N

        cliNeigh.setName("Bairro"); // NOI18N

        cliAddr.setName("Logradouro"); // NOI18N

        jLabel20.setText("E-mail");

        cliEmail.setName("Email"); // NOI18N

        jLabel19.setText("Cidade");

        cliCity.setName("Cidade"); // NOI18N
        cliCity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cliCityActionPerformed(evt);
            }
        });

        save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_add.png"))); // NOI18N
        save.setText("Salvar");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                actionPerformedSave(evt);
            }
        });

        cancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancelar.png"))); // NOI18N
        cancel.setText("Cancelar");
        cancel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedCancelarHandler(evt);
            }
        });
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        try {
            cliNasc.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliNasc.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
        cliNasc.setName("Data_de_Nascimento;Date"); // NOI18N
        cliNasc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                cliNascFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                cliNascFocusLost(evt);
            }
        });

        try {
            cliCep.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliCep.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
        cliCep.setName("CEP"); // NOI18N

        try {
            cliTel.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliTel.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
        cliTel.setName("Telefone"); // NOI18N

        try {
            cliCpf.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliCpf.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
        cliCpf.setName("CPF"); // NOI18N
        cliCpf.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                cliCpfFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                cliCpfFocusLost(evt);
            }
        });

        jLabel3.setText("Endereço");

        jLabel4.setText("CEP");

        jLabel5.setText("Bairro");

        jLabel6.setText("Data Nascimento");

        jLabel7.setText("R.G");

        jLabel10.setText("Telefone");

        jLabel9.setText("C.P.F");

        jLabel15.setText("Carteirinha");

        cliCart.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Não", "Sim" }));
        cliCart.setName("Carteirinha;1"); // NOI18N

        cliFish.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bagre", "Carpa", "Carpa Cabeçuda", "Catfish", "Dourado", "Pacu", "Tilápia" }));
        cliFish.setSelectedIndex(6);
        cliFish.setName("peixe_preferido"); // NOI18N

        jLabel16.setText("Observação");

        jLabel14.setText("Sexo");

        jLabel21.setText("Número");

        cliAddrNum.setName("Numero"); // NOI18N

        jLabel22.setText("Estado");

        cliSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Masculino", "Feminino" }));
        cliSex.setName("Sexo;1"); // NOI18N

        cliState.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SP", "AC", "AL", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "PA", "PB", "PE", "PI", "PR", "RJ", "RR", "RO", "RS", "RN", "SC", "SE", "SP", "TO" }));
        cliState.setName("Estado"); // NOI18N

        jLabelNumPescador.setText("Número do Pescador");

        jLabelFrequencia.setText("Frequencia");

        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/fish-48x48buscar.png"))); // NOI18N
        jButtonBuscar.setText("Buscar");
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarCliente(evt);
            }
        });

        validaData.setForeground(new java.awt.Color(255, 0, 0));
        validaData.setText("Data Inválida");

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_limpar.png"))); // NOI18N
        jButton1.setText("Limpar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        validaCPF.setForeground(new java.awt.Color(255, 0, 0));
        validaCPF.setText("CPF Inválido");

        try {
            cliRg.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###-*")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cliRg.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/pescador.png"))); // NOI18N

        validaSenha6.setForeground(new java.awt.Color(255, 0, 0));

        validaSenha7.setForeground(new java.awt.Color(255, 0, 0));
        validaSenha7.setText("*");

        validaSenha8.setForeground(new java.awt.Color(255, 0, 0));
        validaSenha8.setText("*");

        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setText("*");

        jLabel2.setForeground(new java.awt.Color(255, 0, 0));
        jLabel2.setText("*");

        jLabel8.setForeground(new java.awt.Color(255, 0, 0));
        jLabel8.setText("*");

        jLabel17.setText("Nome");

        jLabel23.setText("Sobrenome");

        jLabel24.setText("Apelido");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(validaSenha6, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel19)
                            .addComponent(jLabel10)
                            .addComponent(jLabel14)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 10, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel24)
                                    .addComponent(jLabel23)
                                    .addComponent(jLabel17))))
                        .addGap(43, 43, 43)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cliNick, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cliSex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(validaSenha7, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(3, 3, 3)
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cliNasc, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cliCity, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 151, Short.MAX_VALUE)
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cliState, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(cliEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addComponent(cliNeigh, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addComponent(cliAddr, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cliCart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
                                .addComponent(jLabelNumPescador)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cliNumPescador, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(cliName, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addComponent(cliLastName, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(cliTel, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(40, 40, 40)
                                .addComponent(cliMob, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(validaSenha8, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(3, 3, 3)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelFrequencia, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(cliCep, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(cliAddrNum, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(cliRg, javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(cliCpf, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(validaCPF))
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel13)
                                                    .addComponent(save, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(cancel)))
                                    .addComponent(cliFrequencia, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(4, 4, 4))
                            .addComponent(validaData)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel16))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cliFish, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(388, 388, 388)))
                .addGap(55, 55, 55))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(cliFish, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(cliCart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cliNumPescador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelNumPescador)
                            .addComponent(jLabelFrequencia)
                            .addComponent(cliFrequencia, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cliName)
                            .addComponent(jLabel9)
                            .addComponent(cliCpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(validaCPF)
                            .addComponent(validaSenha8)
                            .addComponent(jLabel1)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cliLastName)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonBuscar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(cliRg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel23))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(validaSenha6)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel24)
                                    .addComponent(cliNick, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(12, 12, 12)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cliSex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cliNasc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                                    .addComponent(validaData)
                                    .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 16, Short.MAX_VALUE)
                                    .addComponent(validaSenha7))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cliAddr, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel21)
                                    .addComponent(cliAddrNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cliNeigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5))
                                .addGap(7, 7, 7)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cliCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cliState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel22)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(cliCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cliEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cliMob, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cliTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(60, 60, 60))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addGap(43, 43, 43)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel16)
                            .addGap(48, 48, 48))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(save)
                            .addComponent(cancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGap(29, 29, 29))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cliCityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cliCityActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_cliCityActionPerformed

    private void mouseClickedCancelarHandler(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseClickedCancelarHandler
        // TODO add your handling code here:
        cleanScreen();
        menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
    }//GEN-LAST:event_mouseClickedCancelarHandler
    /**
     * Função guarda os dados do formulário
     * falta biblioteca
     */
    //-------- Valida CPF ou CNPJ
  public boolean valida_CpfCnpj(String s_aux)
    {

      s_aux = s_aux.replace(".", "").replace("-", "").replace(" ", "");
      //------- Rotina para CPF
       if (s_aux.length() == 11 )
       {
           if (s_aux.equals("00000000000") || s_aux.equals("11111111111") || s_aux.equals("22222222222") || s_aux.equals("33333333333") || s_aux.equals("44444444444") || s_aux.equals("55555555555") || s_aux.equals("66666666666") || s_aux.equals("77777777777") || s_aux.equals("88888888888") || s_aux.equals("99999999999"))
                return true;  //colocar false depois, estes nao sao validos

           int     d1, d2;
           int     digito1, digito2, resto;
           int     digitoCPF;
           String  nDigResult;
           d1 = d2 = 0;
           digito1 = digito2 = resto = 0;
           for (int n_Count = 1; n_Count < s_aux.length() -1; n_Count++)
           {
              digitoCPF = Integer.valueOf (s_aux.substring(n_Count -1, n_Count)).intValue();
//--------- Multiplique a ultima casa por 2 a seguinte por 3 a seguinte por 4 e assim por diante.
              d1 = d1 + ( 11 - n_Count ) * digitoCPF;
//--------- Para o segundo digito repita o procedimento incluindo o primeiro digito calculado no passo anterior.
              d2 = d2 + ( 12 - n_Count ) * digitoCPF;
           }
//--------- Primeiro resto da divisão por 11.
           resto = (d1 % 11);
//--------- Se o resultado for 0 ou 1 o digito é 0 caso contrário o digito é 11 menos o resultado anterior.
           if (resto < 2)
              digito1 = 0;
           else
              digito1 = 11 - resto;
           d2 += 2 * digito1;
//--------- Segundo resto da divisão por 11.
           resto = (d2 % 11);
//--------- Se o resultado for 0 ou 1 o digito é 0 caso contrário o digito é 11 menos o resultado anterior.
           if (resto < 2)
              digito2 = 0;
           else
              digito2 = 11 - resto;
//--------- Digito verificador do CPF que está sendo validado.
           String nDigVerific = s_aux.substring (s_aux.length()-2, s_aux.length());
//--------- Concatenando o primeiro resto com o segundo.
           nDigResult = String.valueOf(digito1) + String.valueOf(digito2);
//--------- Comparar o digito verificador do cpf com o primeiro resto + o segundo resto.
           return nDigVerific.equals(nDigResult);
        }
//-------- Rotina para CNPJ
        else if (s_aux.length() == 14)
        {
            int soma = 0, aux, dig;
            String cnpj_calc = s_aux.substring(0,12);
            char[] chr_cnpj = s_aux.toCharArray();
//--------- Primeira parte
            for( int i = 0; i < 4; i++ )
            if ( chr_cnpj[i]-48 >=0 && chr_cnpj[i]-48 <=9 )
              soma += (chr_cnpj[i] - 48) * (6 - (i + 1));
            for( int i = 0; i < 8; i++ )
            if ( chr_cnpj[i+4]-48 >=0 && chr_cnpj[i+4]-48 <=9 )
                soma += (chr_cnpj[i+4] - 48) * (10 - (i + 1));
            dig = 11 - (soma % 11);
            cnpj_calc += ( dig == 10 || dig == 11 ) ?
                "0" : Integer.toString(dig);
//--------- Segunda parte
            soma = 0;
            for ( int i = 0; i < 5; i++ )
            if ( chr_cnpj[i]-48 >=0 && chr_cnpj[i]-48 <=9 )
                soma += (chr_cnpj[i] - 48) * (7 - (i + 1));
            for ( int i = 0; i < 8; i++ )
            if ( chr_cnpj[i+5]-48 >=0 && chr_cnpj[i+5]-48 <=9 )
                soma += (chr_cnpj[i+5] - 48) * (10 - (i + 1));
            dig = 11 - (soma % 11);
            cnpj_calc += ( dig == 10 || dig == 11 ) ?
                        "0" : Integer.toString(dig);
            return s_aux.equals(cnpj_calc);
        }
        else
            return false;
    }

private void validaCpf() {

    flagCpf = false;
    flagCpfBD = true;

    if(valida_CpfCnpj(cliCpf.getText().replace(" ", "").replace(".","").replace("-",""))) {   // TODO add your handling code here:
       flagCpf = true;
    }
    else {
        validaCPF.setVisible(true);
        flagCpf = false;
    }
   if(flagCpf) {
            try {
                if(conector.consultaCPFCadastrado(cliCpf.getText().replace(" ", "").replace(".", "").replace("-", ""), "funcionarios"))
                    flagCpfBD = true;
                else
                    flagCpfBD = false;

            } catch (SQLException ex) {
                Logger.getLogger(MenuCadastrarFuncionario.class.getName()).log(Level.SEVERE, null, ex);
                conector = new Conector();
            }
   }
}

private void actionPerformedSave(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionPerformedSave


     if(cliName.getText().length() > 0) {
         if(cliLastName.getText().compareTo("") != 0) {
             if((!cliNasc.getText().equals("  /  /    "))) {
                        if(this.validaData()) {


        try {

            if (this.objetivo.equals("C")) {

                try {
                    this.validaCpf();
                    if(flagCpf && !flagCpfBD) {
                        cliente = readScreen();
                            if (conector.cadastrarCliente(cliente)) {
                                JOptionPane.showMessageDialog(this, "O pescador " + cliente.getNome() + " foi cadastrado", "Confirmação", JOptionPane.WARNING_MESSAGE, iconeOK);
                                cleanScreen();
                                menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());

                            } else {
                                JOptionPane.showMessageDialog(this, "O pescador NÃO foi cadastrado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
                                //menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
                            }
                        
                        } else {
                        if(!flagCpf)
                            JOptionPane.showMessageDialog(this, "Favor informar CPF válido", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);
                        else if(flagCpfBD)
                            JOptionPane.showMessageDialog(this, "CPF já cadastrado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);
                        }
                } catch (SQLException sqle) {

                    Logger.getLogger(MenuCadastrarFuncionario.class.getName()).log(Level.SEVERE, null, sqle);
                    conector = new Conector();
                }                        

            } else {

                try {
                        cliente = readScreen();
                            if (conector.atualizarCadastroCliente(readScreen())) {
                                JOptionPane.showMessageDialog(this, "O cadastro do pescador " + cliente.getNome() + " foi atualizado", "Atualização", JOptionPane.WARNING_MESSAGE, iconeOK);
                                cliente = null;
                                this.cleanScreen();
                                menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());

                            } else {
                                JOptionPane.showMessageDialog(this, "O cadastro NÃO pode ser atualizado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
                                menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
                            }
                        } catch (SQLException sqle) {

                            Logger.getLogger(MenuCadastrarFuncionario.class.getName()).log(Level.SEVERE, null, sqle);
                            conector = new Conector();
                        }
                    }

                } catch (Exception ex) {

                    ex.printStackTrace();
                }
            } else
                 JOptionPane.showMessageDialog(this, "Data de nascimento inválida", "AVISO", JOptionPane.WARNING_MESSAGE, iconeERRO);

            } else
                    JOptionPane.showMessageDialog(this, "Favor preencher o campo Data de nascimento", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);
        } else {
            JOptionPane.showMessageDialog(this, "Favor preencher o campo Sobrenome", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);
        }
     } else {
        JOptionPane.showMessageDialog(this, "Favor preencher o campo Nome", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);
    }
     cliCpf.setEditable(true);

}//GEN-LAST:event_actionPerformedSave

private void jButtonBuscarCliente(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarCliente
    // TODO add your handling code here:

    String cpf = cliCpf.getText().replace(".", "").replace("-", "").replace(" ", "");
    if (cliNumPescador.getText().length() > 0) {
        cliente = new Cliente(Integer.parseInt(cliNumPescador.getText()), cliName.getText(), cliLastName.getText(), cpf);
    } else {
        cliente = new Cliente(0, cliName.getText(), cliLastName.getText(), cpf);
    }
    try {

        Cliente cli = new Cliente();
        cli = conector.consultarClienteParaEditar(cliente, this);
        if(cli.isFlagClienteNaoEncontrado())
                JOptionPane.showMessageDialog(this, "Cliente não encontrado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
//        else
                this.setClientScreen(cli);

        System.out.println(cliente);

    } catch (SQLException ex) {
        Logger.getLogger(MenuCadastrarCliente.class.getName()).log(Level.SEVERE, null, ex);
        conector = new Conector();
    }
    cliCpf.setEditable(false);
}//GEN-LAST:event_jButtonBuscarCliente

private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
    // TODO add your handling code here:
    cleanScreen();
    menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
}//GEN-LAST:event_cancelActionPerformed

private void cliNascFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cliNascFocusLost
    validaData();
}//GEN-LAST:event_cliNascFocusLost

private void cliCpfFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cliCpfFocusLost

    this.validaCpf();
}//GEN-LAST:event_cliCpfFocusLost

private void cliCpfFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cliCpfFocusGained
   validaCPF.setVisible(false);
}//GEN-LAST:event_cliCpfFocusGained

private void cliNascFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cliNascFocusGained
    validaData.setVisible(false);
}//GEN-LAST:event_cliNascFocusGained

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    this.cleanScreen();
    validaCPF.setVisible(false);
    validaData.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed

    public boolean validaData() {
        String[] data = cliNasc.getText().split("/");            
            int dia;  int mes; int ano;
        try {
            dia = Integer.parseInt(data[0]);
            mes = Integer.parseInt(data[1]);
            ano = Integer.parseInt(data[2]);
        } catch (NumberFormatException e) {
            return false;
        }


        try {
            Date dateTest = Cliente.dateCreator.parse(cliNasc.getText());
            long cliTime = dateTest.getTime();
            long sysTime = System.currentTimeMillis();
            if (sysTime < cliTime) {
                    validaData.setVisible(true);
                    return false;
            }
        } catch (ParseException ex) {
            Logger.getLogger(MenuCadastrarCliente.class.getName()).log(Level.SEVERE, null, ex);
        }



        if (mes > 0 && mes <= 12) {

            if (ano % 4 == 0) { //VERIFICA ANO BISSEXTO
                if (mes == 2) {
                    if (dia < 0 || dia > 29) {
                        validaData.setVisible(true);
                        return false;
                    } else {
                        return true;
                    }
                } else {
                    if (dia < 0 || dia > 28) {
                        validaData.setVisible(true);
                        return false;
                    } else {
                        validaData.setVisible(false);
                        return true;
                    }
                }
            } else {
                if (mes == 2) {

                    if (dia < 0 || dia > 28) {
                        validaData.setVisible(true);
                        return false;
                    } else {
                        validaData.setVisible(false);
                        return true;
                    }
                } else if (ano % 2 == 0) {
                    if (dia < 0 || dia > 30) {
                        validaData.setVisible(true);
                        return false;
                    } else {
                        validaData.setVisible(false);
                        return true;
                    }
                } else if (dia < 0 || dia > 31) {
                    validaData.setVisible(true);
                    return false;
                } else {
                    validaData.setVisible(false);
                    return true;
                }

            }
        } else {
            validaData.setVisible(true);
            return false;
        }
    }

    private Cliente readScreen() throws ParseException {

        String cpf, telefone, celular, cep, sexo, estado, rg;

         if(cliCpf.getText().compareTo("   .   .   -  ") != 0)
            cpf = cliCpf.getText().substring(0, 3) + cliCpf.getText().substring(4, 7) + cliCpf.getText().substring(8, 11) + cliCpf.getText().substring(12, 14);
        else
            cpf = "";

        if(cliTel.getText().compareTo("(  )     -    ") != 0)
            telefone = cliTel.getText().substring(1, 3) + cliTel.getText().substring(4, 8) + cliTel.getText().substring(9, 13);
        else
            telefone = "";

        if(cliMob.getText().compareTo("(  )     -    ") != 0)
            celular = cliMob.getText().substring(1, 3) + cliMob.getText().substring(4, 8) + cliMob.getText().substring(9, 13);
        else
            celular = "";

        if(cliCep.getText().compareTo("     -   ") != 0)
            cep = cliCep.getText().substring(0, 5) + cliCep.getText().substring(6, 9);
        else
            cep = "";

               if(cliSex.getSelectedItem().toString().compareTo("") != 0)
            sexo = cliSex.getSelectedItem().toString();
        else
            sexo = "";

        if(cliState.getSelectedItem().toString().compareTo("") != 0)
            estado = cliState.getSelectedItem().toString();
        else
            estado = "";
        if(!cliRg.getText().equals("  .   .   - "))
            rg = cliRg.getText().substring(0,2) + cliRg.getText().substring(3,6) + cliRg.getText().substring(7,10) + cliRg.getText().substring(11);
        else
            rg = "";

        Cliente cli = new Cliente(cpf, cliName.getText(), cliLastName.getText(), cliNick.getText(),
                rg, cliNasc.getText(), cliAddr.getText(), cliAddrNum.getText(), cliNeigh.getText(),
                cliCity.getText(), estado, cep, telefone,
                celular, cliEmail.getText(), cliFish.getSelectedItem().toString(),
                sexo, cliCart.getSelectedItem().toString().substring(0, 1), cliObs.getText());
               cli.setFrequencia(cliFrequencia.isVisible()? Integer.parseInt(cliFrequencia.getText()) : 0);
                cli.setNumeroPescador(cliNumPescador.isVisible()? Integer.parseInt(cliNumPescador.getText()) : 0);
        return cli;
    }

    private void setClientScreen() {
        setClientScreen(cliente);
    }

    public void setClientScreen(Cliente setCli) {
        cliNumPescador.setText(String.valueOf(setCli.getNumeroPescador()));
        cliName.setText(setCli.getNome());
        cliLastName.setText(setCli.getSobrenome());
        cliNick.setText(setCli.getApelido());
        cliAddr.setText(setCli.getLogradouro());
        cliAddrNum.setText(setCli.getNumero());
        cliCep.setText(setCli.getCep());
        cliCity.setText(setCli.getCidade());
        cliCpf.setText(setCli.getCpf());
        cliEmail.setText(setCli.getEmail());
        cliFish.setSelectedItem(setCli.getPeixePreferido());
        cliFrequencia.setText(String.valueOf(setCli.getFrequencia()));
        cliMob.setText(setCli.getCelular());
        cliNasc.setText(setCli.getDataNascimento());
        cliNeigh.setText(setCli.getBairro());
        cliObs.setText(setCli.getObsevacao());
        cliRg.setText(setCli.getRg());
        cliState.setSelectedItem(setCli.getEstado());
        cliTel.setText(setCli.getTelefone());

        if(setCli.getSexo() == null)
            cliSex.setSelectedItem("Masculino");

        else if (setCli.getSexo().toUpperCase().equals("M")) {
            cliSex.setSelectedItem("Masculino");
        } else {
            cliSex.setSelectedItem("Feminino");
        }

        if(setCli.getCarteirinha() == null)
            cliCart.setSelectedItem("Não");
        else if (setCli.getCarteirinha().toUpperCase().equals("N")) {
            cliCart.setSelectedItem("Não");
        } else {
            cliCart.setSelectedItem("Sim");
        }
        cliCart.setSelectedItem(setCli.getCarteirinha());
    }

    private void cleanScreen() {
        cliNumPescador.setText("");
        cliName.setText("");
        cliLastName.setText("");
        cliNick.setText("");
        cliAddr.setText("");
        cliAddrNum.setText("");
        cliCep.setText("");
        cliCity.setText("");
        cliCpf.setText("");
        cliEmail.setText("");
        cliFish.setSelectedIndex(cliFish.getItemCount() - 1);
        cliFrequencia.setText("");
        cliMob.setText("");
        cliNasc.setText("");
        cliNeigh.setText("");
        cliObs.setText("");
        cliRg.setText("");
        cliState.setSelectedIndex(0);
        cliTel.setText("");
        cliSex.setSelectedIndex(0);
        cliCart.setSelectedIndex(0);

    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancel;
    private javax.swing.JFormattedTextField cliAddr;
    private javax.swing.JTextField cliAddrNum;
    private javax.swing.JComboBox cliCart;
    private javax.swing.JFormattedTextField cliCep;
    private javax.swing.JFormattedTextField cliCity;
    private javax.swing.JFormattedTextField cliCpf;
    private javax.swing.JFormattedTextField cliEmail;
    private javax.swing.JComboBox cliFish;
    private javax.swing.JFormattedTextField cliFrequencia;
    private javax.swing.JFormattedTextField cliLastName;
    private javax.swing.JFormattedTextField cliMob;
    private javax.swing.JFormattedTextField cliName;
    private javax.swing.JFormattedTextField cliNasc;
    private javax.swing.JFormattedTextField cliNeigh;
    private javax.swing.JFormattedTextField cliNick;
    private javax.swing.JFormattedTextField cliNumPescador;
    private javax.swing.JTextArea cliObs;
    private javax.swing.JFormattedTextField cliRg;
    private javax.swing.JComboBox cliSex;
    private javax.swing.JComboBox cliState;
    private javax.swing.JFormattedTextField cliTel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelFrequencia;
    private javax.swing.JLabel jLabelNumPescador;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton save;
    private javax.swing.JLabel validaCPF;
    private javax.swing.JLabel validaData;
    private javax.swing.JLabel validaSenha6;
    private javax.swing.JLabel validaSenha7;
    private javax.swing.JLabel validaSenha8;
    // End of variables declaration//GEN-END:variables

    public void setScreen(Pessoa pessoa) {
        setClientScreen((Cliente) pessoa);
    }

    public void setScreen2(ServicoPesca servPesca) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    }